<template>
  <!-- 登录页 -->
  <div class="page-login">
    <div class="logo">
      <img src="static/rdlogo.png" alt="">
    </div>
    <div class="form-box">
      <div class="title-box">
        <div class="e-title">RT-LIMS</div>
        <div class="title">实验室信息管理系统</div>
      </div>
      <el-col :xl="6" :lg="7">
        <el-form :model="loginForm" :rules="rules" ref="loginForm" label-width="80px" label-position="center">
          <el-form-item label="" prop="username" style="width: 380px">
            <el-input v-model="loginForm.email" prefix-icon="el-icon-user-solid"
                      placeholder="请输入用户名"></el-input>
          </el-form-item>
          <el-form-item label="" prop="password" style="width: 380px">
            <el-input v-model="loginForm.pwd" type="password" placeholder="请输入密码"
                      prefix-icon="el-icon-s-goods"></el-input>
          </el-form-item>

          <!--                <el-form-item label="记住密码" style="width: 380px">-->
          <!--                    <el-switch v-model="loginForm.delivery"></el-switch>-->
          <!--                </el-form-item>-->


          <el-form-item style="width: 380px">
            <el-button type="primary" @click="submitForm('loginForm')" style="width: 45%">登陆</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </div>
    <div class="footer">
      Copyright ©2021 上海研鼎信息技术有限公司
    </div>
  </div>
</template>

<script>
import settings from "../../../config/settings";
import Vue from 'vue';

export default {
  data() {
    return {
      loginForm: {
        email: "",
        pwd: "",
      },
      rules: {
        email: [
          {required: true, message: '请输入用户名', trigger: 'blur'}
        ],
        pwd: [
          {required: true, message: '请输入密码', trigger: 'blur'}
        ],
      },

      checked: false
    };
  },
  methods: {
    submitForm(formName) {
      console.log(  this.loginForm.email,
       this.loginForm.pwd)
      this.$refs[formName].validate((valid) => {
        console.log(valid)
        if (valid) {
          // this.$router.push("/")
          this.$axios.post(this.$settings.BASE_URL_USER+'user/user/login/', {
            username: this.loginForm.email,
            password: this.loginForm.pwd
          }).then(res => {
            if (res.data.code == 100) {
              localStorage.setItem('token', res.data.token)
              const jwt = res.headers['authorization']
              this.$router.push("/tof_gimbalguide")
            }else{
              this.$message.error(res.data.msg);
            }

          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },

  },
};
</script>

<style lang="less">
.page-login {
  width: 100%;
  height: 100%;
  position: relative;
  background: url(/static/backg.jpg);
  background-size: cover;

  .logo {
    position: absolute;
    top: @h*64vh;
    left: @w*108vw;
  }

  .footer {
    position: absolute;
    bottom: @h*40vh;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.25rem;
    font-family: Arial;
    font-weight: 400;
    color: #F1F3F4;
  }

  .form-box {
    padding: @h*79vh @w*90vw @h*71vh;
    position: absolute;
    width: @w*400vw;
    top: 50%;
    right: @w*208vw;
    transform: translateY(-50%);
    height: @h*550vh;
    // border: 1px solid #666;
    border-radius: 0.5rem;
    background: #f5f6fa;

    .title-box {
      margin-bottom: @h*83vh;

      .e-title {
        text-align: center;
        height: @h*67vh;
        font-size: 2.625rem;
        font-family: Arial;
        font-weight: bold;
        color: #168fff;
        line-height: @h*67vh;
      }

      .title {
        text-align: center;
        height: @h*67vh;
        font-size: 2.625rem;
        font-family: Source Han Sans CN;
        font-weight: bold;
        color: #168fff;
        line-height: @h*67vh;
      }
    }

    .form {
      margin-bottom: @h*60vh;

      div:first-child {
        margin-bottom: @h*50vh;
      }

      .el-input {
        font-size: 1.125rem;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #777777;
      }

      .el-input__inner {
        height: @h*60vh;
        border: none;
        background: #262626;
        font-size: 1.125rem;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #777777;
        line-height: @h*60vh;
        padding-left: @w*40vw;
      }

      .el-input__prefix,
      .el-input__suffix {
        height: @h*60vh;
        font-size: 1.125rem;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #777777;
        line-height: @h*60vh;
      }
    }

    .remember-box {
      margin-bottom: @h*40vh;
      line-height: 1;

      .el-checkbox__label {
        font-size: 1.125rem;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #666666;
        line-height: 1;
      }
    }

    .login-btn {
      text-align: center;

      .el-button {
        width: @w*240vw;
        height: @h*60vh;

        span {
          font-size: 1.25rem;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #ffffff;
        }
      }
    }
  }
}
</style>
